<template>
  <div>
    <van-button type="primary" @click="logout">退出登录</van-button>
  </div>
</template>

<script>
export default {
  methods: {
    async logout() {
      try {
        let res = await this.$axios.get("/user/logout");
        // 更新token,isLogin,phone的值
        this.$store.commit("updateLoginState", false);
        this.$store.commit("updatePhone", '');
        this.$store.commit("updateToken", '');
        this.$router.push('/my')
      } catch (error) {
        console.log(error);
      }
    }
  }
};
</script>

<style>
</style>